/*
=======================================================================

  Console and Server commands for BotS.
  These command will help us set up the proper lists for use in the
  UI menus.

=======================================================================
*/

#include "cg_local.h"
#include "cgame_BOTS.h"


/////////////////////////////////////////////
// Console Commands
// This is used to set up data lists for special menus.
// It is possible we can move this to the server.
qboolean BOTS_CG_ConsoleCommand(const char* cmd)
{	
	if (Q_stricmp (cmd, "rejoin") == 0)
	{
		trap_SendClientCommand("setup_rejoin_data");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "disguise") == 0)
	{
		trap_SendClientCommand("setup_disguise_data");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "create") == 0)
	{
		trap_SendClientCommand("setup_create_data");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "genresearch") == 0)
	{
		trap_SendClientCommand("setup_genresearch_data");
		return qtrue;
	}
	
	/////////////////////////////////////////////

	// more complicated menus
	if (Q_stricmp (cmd, "vote") == 0)
	{
		trap_SendClientCommand("setup_vote_list");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "mute") == 0)
	{
		trap_SendClientCommand("setup_mute_list");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "unmute") == 0)
	{
		trap_SendClientCommand("setup_unmute_list");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "promote") == 0)
	{
		trap_SendClientCommand("setup_promote_list");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "demote") == 0)
	{
		trap_SendClientCommand("setup_demote_list");
		return qtrue;
	}
	else if (Q_stricmp (cmd, "video") == 0)
	{
		trap_SendClientCommand("setup_video_list");
		return qtrue;
	}

	return qfalse;
}

/////////////////////////////////////////////
// Server Commands
// These are commands passed from the server after a data list
// for a special menu has been set up.  We then call to the 
// appropriate menu.
qboolean BOTS_CG_ServerCommand(const char* cmd)
{
	if (Q_stricmp (cmd, "server_myclass") == 0 )
	{
		const char* arg2;
		arg2 = CG_Argv(1);
		trap_SendConsoleCommand(va("exec %s.cfg\n", arg2));
		return qtrue;
	}	
	
	// I have put a space after each command because it was
	// concatenating the +button attack or something onto
	// the end of the command - no idea why.
	else if (Q_stricmp (cmd, "changeclass") == 0)
	{
		trap_SendConsoleCommand("UI_show_class_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "rejoin_data_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_rejoin_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "create_data_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_create_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "disguise_data_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_disguise_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "genresearch_data_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_genresearch_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "classresearch_data_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_classresearch_menu ");
		return qtrue;
	}

	/////////////////////////////////////////////

	else if (Q_stricmp(cmd, "vote_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_vote_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "mapvote_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_mapvote_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "mute_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_mute_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "unmute_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_unmute_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "promote_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_promote_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "demote_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_demote_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "video_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_video_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "heal_list_complete") == 0 ) 
	{
		trap_SendConsoleCommand("UI_show_heal_menu ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "bots_table") == 0 ) 
	{
		
		BOTS_TablePrint( CG_Argv(1) );
		return qtrue;
	}
	else if (Q_stricmp(cmd, "walk_client") == 0 ) 
	{
		trap_SendConsoleCommand("cl_run 0 ");
		return qtrue;
	}
	else if (Q_stricmp(cmd, "set_cheat_vars") == 0 ) 
	{
		trap_SendConsoleCommand("r_railsegmentlength 40\nr_railwidth 20\nr_railCoreWidth 5\n");
		return qtrue;
	}

	return qfalse;
}
